from random import randint  # from 模块名 import 方法名
import requests
import time


def randintTest():
    num = randint(1, 100)  # 左右都是闭区间
    print(num)


def join_test():
    word = "hello world"
    newWord = ",".join(word)
    print(newWord)


def brAndcon():
    i = 0
    while i < 5:
        i += 1
        for j in range(3):
            print(j)
            if j == 2:
                break
        for k in range(3):
            if k == 2:
                continue
            print(k)
        if i > 3:
            break
        print(i)


def TianQi():
    while True:
        city = input('请输入城市,回车退出:\n')
        if not city:
            break
        req = requests.get('http://wthrcdn.etouch.cn/weather_mini?city=%s' %
                           city)
        dic_city = req.json()
        city_data = dic_city.get('data')
        try:
            if city_data:
                city_forecast = city_data['forecast'][0]  # 下面的都可以换成'get'方法
                print(city_forecast.get('date'))
                print(city_forecast.get('high'))
                print(city_forecast.get('low'))
                print(city_forecast.get('type'))
            else:
                print('未获得')
        except:
            print('查询失败')


def time_epoch():
    starttime = time.time()
    print("start:%f" % starttime)
    for i in range(1, 10):
        print(i, end=" ")
        time.sleep(1)
    endtime = time.time()
    print('total time:%f' % (endtime - starttime))


if __name__ == "__main__":
    # randintTest()
    # join_test()
    # brAndcon()
    # TianQi()
    time_epoch()